package com.tuozixuan.javafx.other;

import javafx.scene.Group;
import javafx.scene.paint.Color;
import javafx.scene.shape.Line;
import javafx.scene.shape.StrokeLineCap;
import javafx.scene.shape.StrokeLineJoin;
import javafx.scene.shape.StrokeType;

public class ThreeFoldLine {
	
	private Group group;

	public ThreeFoldLine(double startX, double startY, double endX, double endY) {
		
		double middleX = startX + (endX - startX) /2 ;
		
		Line line1 = new Line(startX, startY, middleX, startY);
		Line line2 = new Line(middleX, startY, middleX, endY);
		Line line3 = new Line(middleX, endY, endX, endY);
		this.set(line1);
		this.set(line2);
		this.set(line3);
		group = new Group(line1, line2, line3);
	}
	
	public Group getGroup() {
		return this.group;
	}
	
	private void set(Line line) {
		// True表示打开反锯齿，false表示关闭反锯齿。
		line.setSmooth(true);
		
		// 设置形状的笔划线的颜色
		line.setStroke(Color.BLACK);
		// 设置线的宽度
		line.setStrokeWidth(3);
		// 设置在Shape节点的边界周围绘制描边的位置
		line.setStrokeType(StrokeType.CENTERED);
		
		// 在线或路径的末尾设置帽样式
		line.setStrokeLineCap(StrokeLineCap.ROUND);
		
		// 当线相遇时设置装饰
		line.setStrokeLineJoin(StrokeLineJoin.ROUND);
	}
}
